// 校验是否必填
export function requiredValidate({required = true, message, name, trigger = 'blur change'}) {
  return {
    required: required,
    message: message || `${name || ''}不能为空`,
    trigger: trigger
  }
}
// 校验类型
export function typeValidate({type = 'string', message, name, trigger = 'blur change'}) {
  return {
    type: type,
    message: message || `${name || ''}类型不正确`,
    trigger: trigger
  }
}
// 校验字符最大长度
export function maxValidate({type = 'string', max = 999, message, name, trigger = 'blur change'}) {
  return {
    type: type,
    max: max,
    message: message || `${name || ''}字符不能超过${max}个`,
    trigger: trigger
  }
}
// 校验字符最小长度
export function minValidate({type = 'string', min = 0, message, name, trigger = 'blur change'}) {
  return {
    type: type,
    min: min,
    message: message || `${name || ''}字符不能小于${min}个`,
    trigger: trigger
  }
}
// 校验不能含有特殊字符
export function stringValidate({type = 'string', message, name, trigger = 'blur change'}) {
  return {
    type: type,
    pattern: /^((?![`!@#$%^&*<>?:'"“”‘’]).)*$/,
    message: message || `${name || ''}不能含有特殊字符`,
    trigger: trigger
  }
}
// 自定义正则输入
export function patternValidate({type = 'string', pattern = /^/, message, name, trigger = 'blur change'}) {
  return {
    type: type,
    pattern: pattern,
    message: message || `${name || ''}格式不正确`,
    trigger: trigger
  }
}
// 校验是否为邮箱
export function emailValidate({message, trigger = 'blur change'}) {
  return {
    type: 'email',
    message: message || '邮箱格式不正确',
    trigger: trigger
  }
}
// 校验是否为手机号
export function phoneValidate({message, trigger = 'blur change'}) {
  return {
    type: 'string',
    pattern: /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/,
    message: message || '手机号格式不正确',
    trigger: trigger
  }
}
// 校验是否为IP地址
export function ipValidate({message, trigger = 'blur change'}) {
  return {
    type: 'string',
    pattern: /^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$/,
    message: message || 'IP格式不正确',
    trigger: trigger
  }
}
// 校验是否为MAC地址
export function macValidate({message, trigger = 'blur change'}) {
  return {
    type: 'string',
    pattern: /^([\dA-Fa-f]{2}(:[\dA-Fa-f]{2}){5})|([\dA-Fa-f]{2}([-][\dA-Fa-f]{2}){5})$/,
    message: message || 'MAC格式不正确',
    trigger: trigger
  }
}
// 校验是否为身份证
export function identityValidate({message, trigger = 'blur change'}) {
  return {
    type: 'string',
    pattern: /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
    message: message || '身份证格式不正确',
    trigger: trigger
  }
}
// 校验是否为数字不包含负号以及小数点
export function allNumberValidate({message, trigger = 'blur change'}) {
  return {
    type: 'string',
    pattern: /^([1-9]\d*|0)$/,
    message: message || '数字格式不正确',
    trigger: trigger
  }
}
// 校验是否为数字包含负号，小数点
export function numberValidate({message, trigger = 'blur change'}) {
  return {
    type: 'string',
    pattern: /^\-?([1-9]\d*|0)(\.[1-9]{1,9})?$/,
    message: message || '数字格式不正确',
    trigger: trigger
  }
}
// 校验是否为纯汉字
export function chineseValidate({message, trigger = 'blur change'}) {
  return {
    type: 'string',
    pattern: /^[\u4e00-\u9fa5]*$/,
    message: message || '只能输入汉字',
    trigger: trigger
  }
}
// 校验不能包含汉字
export function nochineseValidate({message, trigger = 'blur change'}) {
  return {
    type: 'string',
    pattern: /^[^\u4e00-\u9fa5]{0,}$/,
    message: message || '不能含有汉字',
    trigger: trigger
  }
}
